// 注册自定义指令
export default {
    bind (el, binding) {
        let oDiv = el
        oDiv.onmousedown = (e) => {
            let disX = e.clientX - oDiv.offsetLeft
            let disY = e.clientY - oDiv.offsetTop
            //  获取type属性 （x/y）
            let type = oDiv.getAttribute('data-type')
            //  div父级的宽高
            let parentWidth = oDiv.parentNode.offsetWidth
            let parentHeight = oDiv.parentNode.offsetHeight
            //  div宽高
            let divWidth = oDiv.offsetWidth
            let divHeight = oDiv.offsetHeight
            document.onmousemove = (e) => {
            let l = e.clientX - disX
            let t = e.clientY - disY
            // v-drag 绑定参数接收的参数
            binding.value({ x: e.pageX, y: e.pageY, l, t, type, parentWidth, parentHeight, divWidth, divHeight })
            // 阻止默认事件
            e.preventDefault()
            }
            document.onmouseup = (e) => {
            document.onmousemove = null
            document.onmouseup = null
            }
        }
    }
}
  